<html>
<head><meta charset="utf-8"><title>How to get the span of a function givent the `DefId`? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20to.20get.20the.20span.20of.20a.20function.20givent.20the.20.60DefId.60.3F.html">How to get the span of a function givent the `DefId`?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="235071368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20to%20get%20the%20span%20of%20a%20function%20givent%20the%20%60DefId%60%3F/near/235071368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Henry Boisdequin <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20to.20get.20the.20span.20of.20a.20function.20givent.20the.20.60DefId.60.3F.html#235071368">(Apr 18 2021 at 13:14)</a>:</h4>
<p>I have the <code>DefId</code> of a function, how do I get its span?</p>



<a name="235071460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20to%20get%20the%20span%20of%20a%20function%20givent%20the%20%60DefId%60%3F/near/235071460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20to.20get.20the.20span.20of.20a.20function.20givent.20the.20.60DefId.60.3F.html#235071460">(Apr 18 2021 at 13:16)</a>:</h4>
<p>You have the def_span query, which gives you the signature's span.</p>



<a name="235071474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20to%20get%20the%20span%20of%20a%20function%20givent%20the%20%60DefId%60%3F/near/235071474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20to.20get.20the.20span.20of.20a.20function.20givent.20the.20.60DefId.60.3F.html#235071474">(Apr 18 2021 at 13:16)</a>:</h4>
<p>For <em>local</em> functions, you have <code>tcx.hir().span_with_body</code>.</p>



<a name="235073757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20to%20get%20the%20span%20of%20a%20function%20givent%20the%20%60DefId%60%3F/near/235073757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Henry Boisdequin <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20to.20get.20the.20span.20of.20a.20function.20givent.20the.20.60DefId.60.3F.html#235073757">(Apr 18 2021 at 13:54)</a>:</h4>
<p>Thanks!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>